﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Excel;

namespace ObjectModel.Excel.Old
{

    /// <summary>
    /// Encapsulates a serializable range object using a literal range reference.
    /// </summary>
    public class LiteralRange : LiteralRangeBase {

        [XmlIgnore]
        public override Range Range
        {
            get
            {
                Range range;
                
                // Try getting the range from it's parent worksheet. This will
                // open the range's parent workbook if it is currently closed.
                try { range = Worksheet.Range[Address]; }
                catch (COMException) { throw new InvalidOperationException("Could not resolve range from literal reference."); }

                return range;
            }
			set { base.Range = value;  }
        }
    }
}
